<div class="grid_3 alpha"><input id="create" value="Crear Nueva Asociación Cliente/Plan" type="button" onclick="window.location = '/clients_planes/edit/0';"/></div>
<div class="grid_6 omega" style="text-align:right;">
    <?php echo $paginator->prev()." ["; ?>
    <?php echo $paginator->numbers(); ?>
    <?php echo "] ".$paginator->next(); ?>
    <?php echo "&nbsp;&nbsp;[".$paginator->counter()."]"; ?>
</div>
<div class="clear"></div>

<?php echo $this->Form->create('ClientsPlan', array(
										'url'           => array('controller' => 'clients_planes', 'action' => 'index'),
										'inputDefaults' => array('label' => false, 'div' => false)
										)
								); ?>
    Filtrar por: <input type='text' name='filtro' value='<?php echo $filtro;?>' style='width:200px;height:24px;margin:4px;'>
    <input type='submit' value='Filtrar'>    
    <?php if (!empty($filtro)) {?>
        <input id="limpiar" value="Limpiar Filtro" type="button" onclick="window.location = '/clients_planes/limpiar_filtro';"/>
    <?php } ?>
    
</form>

<?php echo $this->Form->create('ClientsPlan', array(
										'url'           => array('controller' => 'planes', 'action' => 'delete'),
										'inputDefaults' => array('label' => false, 'div' => false)
										)
								); ?>
    <br />
    <table width="100%">
        <thead>
            <tr>
                <th width="30"><?php echo $this->Paginator->sort('activo');?></th>
                <th width="20"><?php echo $this->Paginator->sort('client_id');?></th>
                <th><?php echo $this->Paginator->sort('plan_id');?></th>
				<th><?php echo $this->Paginator->sort('Pac.Act','pacientes_actuales');?></th>
				<th><?php echo $this->Paginator->sort('fecha_alta');?></th>
            </tr>
        </thead>
        <tbody>
        
    	<?php $i = 0;
    	foreach ($clientes_planes as $cp):
    		$class = null;
    		if ($i++ % 2 == 0) { $class = ' class="altrow"'; }

			$fecha = $cp['ClientsPlan']['fecha_alta'];
			$ano   = date("Y", strtotime($fecha));
			$mes   = date("m", strtotime($fecha));
			$dia   = date("d", strtotime($fecha));
			$fecha = "$dia/$mes/$ano";
		
    	?>
            <tr>
                <td style="text-align:center;">
					<?php if ($cp['ClientsPlan']['activo'] == 1 ) { ?>
						<input name="data[Delete][<?php echo $cp['ClientsPlan']['id'];?>]" type="checkbox" checked='checked' readonly='readonly' disabled='disabled'/>
					<?php } else { ?>
						<input name="data[Delete][<?php echo $cp['ClientsPlan']['id'];?>]" type="checkbox" readonly='readonly' disabled='disabled'/>
					<?php } ?>
				</td>

                <td>
                    <?php echo $this->Html->link($cp['Clients']['name'],
                                array('controller' => 'clients_planes', 'action' => 'edit/'.$cp['ClientsPlan']['id'])); ?> 
                </td>     
                <td><?php echo $cp['Plan']['name']." [{$cp['Plan']['maximo_pacientes']}]"; ?> </td>     
				<td style="text-align:right;width:50px;;"><?php echo $cp['ClientsPlan']['pacientes_actuales']; ?> </td>     

				<td><?php echo $fecha;?></td>                           
				
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    
	<br />    
	<div class="clear"></div>

	<div class="grid_3 alpha">
		&nbsp;
	</div>
	<div class="grid_6 omega" style="text-align:right;">
		<?php echo $paginator->prev()." ["; ?>
		<?php echo $paginator->numbers(); ?>
		<?php echo "] ".$paginator->next(); ?>
		<?php echo "&nbsp;&nbsp;[".$paginator->counter()."]"; ?>
	</div>
	<div class="clear"></div>
	<br />
	<div class="grid_3 alpha"><input id="create" value="Crear Nueva Asociación Cliente/Plan" type="button" onclick="window.location = '/clients_planes/edit/0';"/></div>
	<div class="clear"></div>
    
</form>